import 'package:intl/intl.dart';

String formatTimestamp(int timestamp) {
  
  DateTime date = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
  Duration diff = DateTime.now().difference(date);
  
  if(diff.inDays > 30) {
    return DateFormat('yyyy-MM-dd').format(date);
  } else if (diff.inDays >= 1) {
    return '${diff.inDays}天前';
  } else if (diff.inHours >= 1) {
    return '${diff.inHours}小时前';
  } else if (diff.inMinutes >= 1) {
    return '${diff.inMinutes}分钟前';
  } else {
    return '刚刚';
  }
}
